# delimit ;
capture drop var_eps var_b sd_b wstar;

quietly metareg beta, wsse(se_beta) eb;
scalar tau2=e(tau2);
scalar I2 = e(I2);

quietly metareg beta if lab==0, wsse(se_beta) eb;
scalar ntau2=e(tau2);
scalar nI2 = e(I2);

quietly metareg beta if lab==1, wsse(se_beta) eb;
scalar ltau2=e(tau2);
scalar lI2 = e(I2);

gen var_eps = se_beta^2;
gen var_b = ntau2 + var_eps if ~lab;
replace var_b = ltau2 + var_eps if lab;

gen sd_b = sqrt(var_b);
gen wstar = 1/var_b;
